package org.example.service;

import java.time.LocalDate;
import java.util.Locale;
import java.util.Scanner;

public class Work2 {
    /**
     * 从身份证号码中提取出公民的生日信息
     */
    public void Id() {
        System.out.println("输入18位生份证号码");
        Scanner sc = new Scanner(System.in);
        String id = sc.next();
        if (!id.matches("([0-9]{18}|[0-9]{17}X)")) {
            System.err.println("请输入18位身份证号码");
        } else {
            id.substring(6, 14);
            StringBuffer birthday = new StringBuffer();
            birthday.append(id.substring(6, 14));
            birthday.insert(4, "年");
            birthday.insert(7, "月");
            birthday.insert(10, "日");
            System.out.println("这个人的生日是" + birthday);

        }
    }

    public static void main(String[] args) {
        Work2 work2 = new Work2();
        work2.Id();
    }
}
